<html>
<head>
    <script src="/webjars/jquery/3.3.1-1/jquery.min.js"></script>
    <script src="/webjars/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="/webjars/angularjs/1.7.4/angular.js"></script>
    <link type="text/css" rel="stylesheet" href="/webjars/bootstrap/3.3.7/css/bootstrap.css" />
    <script>
            var app = angular.module('mainApp',[]);
            app.config(['$locationProvider', function($locationProvider) {
              $locationProvider.html5Mode({
                enabled:true,
                requireBase:false
              });
            }]);
            app.controller('confCtrl',function($location,$scope,$http){
                 $scope.getNgList = function(){
                    $http({
                        method:'GET',
                        url:'/getconftxt',
                        params:{'pid':$location.search().pid}
                    }).then(function successCallback(response){
                        $scope.txtconf = response.data;
                    },function errorCallback(response){
                        alert("error: " + response.data);
                    });
                };

                $scope.getNgList();

                $scope.reload = function(){
                    $http({
                        method:'POST',
                        url:'/reload',
                        data:{
                            conf:$scope.txtconf,
                            pid:$location.search().pid
                        },
                    }).then(function successCallback(response){
                        alert("sucess");
                        window.location="/";
                    },function errorCallback(response){
                        alert("error");
                    });
                };
            });

        </script>
</head>

<body ng-app="mainApp">
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <h3>
                Nginx Ctrl Panel
            </h3>
        </div>
    </div>
    <div class="row-fluid"  ng-controller="confCtrl">
        <div class="span12">
            <textarea ng-model="txtconf" style="width:100%;height:70%">

            </textarea>
            <button ng-click='reload()'> reload </button>
        </div>
    </div>
</div>
</body>
</html>